package com.nmgsr.ptmsapp.adapter;

import android.annotation.SuppressLint;

import androidx.annotation.NonNull;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.viewholder.BaseViewHolder;
import com.nmgsr.beans.responsedao.PtmsBorrowRecordRes;
import com.nmgsr.beans.responsedao.PtmsWarnTestRes;
import com.nmgsr.ptmsapp.R;
import com.nmgsr.ptmsapp.utils.DateUtils;

public class ListPtmsBorrowRecordAdapter extends BaseQuickAdapter<PtmsBorrowRecordRes, BaseViewHolder> {
    public ListPtmsBorrowRecordAdapter() {
        super(R.layout.list_ptms_borrow_record_item);
    }

    @SuppressLint("ResourceAsColor")
    @Override
    protected void convert(@NonNull BaseViewHolder baseViewHolder, PtmsBorrowRecordRes list) {
        baseViewHolder.setText(R.id.tv_name, list.getToolName());
        baseViewHolder.setText(R.id.tv_epc,"标签:"+ list.getEpc());
        if (list.getRecordState().equals("0")){
            baseViewHolder.setText(R.id.tv_recordState, "出库");
            baseViewHolder.setTextColor(R.id.tv_recordState, 0xFF3cb371);
            try {
                String formattedScrapDate = DateUtils.formatDate(list.getRecordTime(), "yyyy-MM-dd HH:mm:ss", "yyyy年MM月dd日 HH:mm:ss");
                baseViewHolder.setText(R.id.tv_recordTime, "出库时间：" + formattedScrapDate);
                baseViewHolder.setTextColor(R.id.tv_recordTime, 0xFF3cb371);

            } catch (Exception e) {
                // 如果你字段可能为空，可以统一处理异常或默认值
                baseViewHolder.setText(R.id.tv_recordTime, "日期格式错误");
            }
        }else if (list.getRecordState().equals("1")){
            baseViewHolder.setText(R.id.tv_recordState, "入库");
            baseViewHolder.setTextColor(R.id.tv_recordState, 0xFF1296DB);
            try {
                String formattedScrapDate = DateUtils.formatDate(list.getRecordTime(), "yyyy-MM-dd HH:mm:ss", "yyyy年MM月dd日 HH:mm:ss");
                baseViewHolder.setText(R.id.tv_recordTime, "入库时间：" + formattedScrapDate);
                baseViewHolder.setTextColor(R.id.tv_recordTime, 0xFF000000);

            } catch (Exception e) {
                // 如果你字段可能为空，可以统一处理异常或默认值
                baseViewHolder.setText(R.id.tv_recordTime, "日期格式错误");
            }
        }



    }
}
